<?php
// +----------------------------------------------------------------------
// | OneThink [ WE CAN DO IT JUST THINK IT ]
// +----------------------------------------------------------------------
// | Copyright (c) 2013 http://www.onethink.cn All rights reserved.
// +----------------------------------------------------------------------
// | Author: 麦当苗儿 <zuojiazi@vip.qq.com> <http://www.zjzit.cn>
// +----------------------------------------------------------------------

namespace Home\Controller;
use OT\DataDictionary;
header("Content-type: text/html; charset=utf-8");
/**
 * 机构控制器
 */
class FinanceController extends HomeController
{

    /**
     * 检测是否登录
     * */
    public function _initialize()
    {
        if(empty(session('user_id'))){
            header('Location: ' . U('/Home/Login/Login'));exit;
        }else{
            //再来判断权限
            if(session('Supertube')==1){
                //超管 拥有所有权限
            }else{
                $id=session('user_id');//不是超管的时候 user_id是account_number的主键ID
                $jurisdiction=M('account_number')->where("id=$id")->getField('jurisdiction');
                $action_name=ACTION_NAME;
                if($action_name == statistics || $action_name == Statistics){
                    //访问数据统计
                    $domain = strstr($jurisdiction, ',12,');
                    if(!$domain){
                        $this->error('没有访问权限');
                    }
                }elseif($action_name == order || $action_name == Order){
                    //排行榜
                    $domain = strstr($jurisdiction, ',13,');
                    if(!$domain){
                        $this->error('没有访问权限');
                    }
                }elseif($action_name == charge || $action_name == Charge){
                    //线索列表
                    $domain = strstr($jurisdiction, ',14,');
                    if(!$domain){
                        $this->error('没有访问权限');
                    }
                }
            }
        }
    }

    /**
     * Mr.Jiang
     * 交易管理
     */
    public function order()
    {
        $iid = session("iid");
        $map['a.iid'] = array('eq', $iid);

        if (!empty($_REQUEST['type'])) {
            $map['a.type'] = array('eq', $_REQUEST['type']);
            $this->assign('type', $_REQUEST['type']);
        }

        if ($_REQUEST['mobile'] != '') {
            $map['c.mobile'] = array('like', '%' . $_REQUEST['mobile'] . '%');
            $this->assign('mobile', $_REQUEST['mobile']);
        }
        /*if ($_REQUEST['username'] != '') {
            $map['c.username'] = array('like', '%' . $_REQUEST['username'] . '%');
            $this->assign('username', $_REQUEST['username']);
        }

        if ($_REQUEST['id_card'] != '') {
            $map['c.id_card'] = array('like', '%' . $_REQUEST['id_card'] . '%');
            $this->assign('id_card', $_REQUEST['id_card']);
        }*/

        if ($_REQUEST['order_sn'] != '') {
            $map['a.order_sn'] = array('like', '%' . $_REQUEST['order_sn'] . '%');
            $this->assign('order_sn', $_REQUEST['order_sn']);
        }

        if (!empty($_REQUEST['start_time']) && !empty($_REQUEST['end_time'])) {
            $map['a.create_time'] = array(array('egt', strtotime($_REQUEST['start_time'])), array('elt', strtotime($_REQUEST['end_time'])), 'AND');
            $this->assign('start_time', $_REQUEST['start_time']);
            $this->assign('end_time', $_REQUEST['end_time']);
        } else {
            if (!empty($_REQUEST['start_time'])) {
                $map['a.create_time'] = array('egt', strtotime($_REQUEST['start_time']));
                $this->assign('start_time', $_REQUEST['start_time']);
            }
            if (!empty($_REQUEST['end_time'])) {
                $map['a.create_time'] = array('elt', strtotime($_REQUEST['end_time']));
                $this->assign('end_time', $_REQUEST['end_time']);
            }
        }

        $count = D('order a')->join('left join teach_ucenter_member c on a.uid = c.id')->where($map)->count();
        $Page = new \Think\Page($count, 10, array('type' => $_REQUEST['type'], 'mobile' => $_REQUEST['mobile'], 'order_sn' => $_REQUEST['order_sn'], 'start_time' => $_REQUEST['start_time'], 'end_time' => $_REQUEST['end_time']));// 实例化分页类 传入总记录数和每页显示的记录数(25)
        $list = D('order a')->field('a.*,c.username,c.mobile,c.id_card')->join('left join teach_ucenter_member c on a.uid = c.id')->where($map)->order('a.id desc')->limit($Page->firstRow . ',' . $Page->listRows)->order('id desc')->select();
        foreach ($list as $key => $item) {
            //单价
            $price = D('vice_order')->where(array('order_id' => $item['id']))->SUM('price');
            $list[$key]['price'] = $price ? $price : 0;

            $course_name = "";
            $price = 0.00;
            $vice_order = D('vice_order')->where(array('order_id'=>$item['id']))->select();
            foreach ($vice_order as $k=>$vo) {
                $course_name .= $vo['name'].",";
                $price = $price+$vo['old_price'];
            }
            $list[$key]['course_name'] = $course_name;
            $list[$key]['price'] = $price;

            $list[$key]['pay_time'] = $item['pay_time']?date('Y-m-d',$item['pay_time']):'-';
        }

        $this->assign('_list', $list);
        $show = $Page->show();// 分页显示输出
        $this->assign("_page", $show);

        $this->assign('cur','交易管理');
        $this->display();
    }


    public function order123()
    {
        $iid = session("iid");
        $map['a.iid'] = array('eq', $iid);

        if (!empty($_REQUEST['type'])) {
            $map['a.type'] = array('eq', $_REQUEST['type']);
            $this->assign('type', $_REQUEST['type']);
        }else {
            $map['a.type'] = array(array('eq',1),array('eq',2),array('eq',3),'OR');
        }

        if ($_REQUEST['mobile'] != '') {
            $map['c.mobile'] = array('like', '%' . $_REQUEST['mobile'] . '%');
            $this->assign('mobile', $_REQUEST['mobile']);
        }
        /*if ($_REQUEST['username'] != '') {
            $map['c.username'] = array('like', '%' . $_REQUEST['username'] . '%');
            $this->assign('username', $_REQUEST['username']);
        }

        if ($_REQUEST['id_card'] != '') {
            $map['c.id_card'] = array('like', '%' . $_REQUEST['id_card'] . '%');
            $this->assign('id_card', $_REQUEST['id_card']);
        }*/

        if ($_REQUEST['order_sn'] != '') {
            $map['a.order_sn'] = array('like', '%' . $_REQUEST['order_sn'] . '%');
            $this->assign('order_sn', $_REQUEST['order_sn']);
        }

        if (!empty($_REQUEST['start_time']) && !empty($_REQUEST['end_time'])) {
            $map['a.create_time'] = array(array('egt', strtotime($_REQUEST['start_time'])), array('elt', strtotime($_REQUEST['end_time'])), 'AND');
            $this->assign('start_time', $_REQUEST['start_time']);
            $this->assign('end_time', $_REQUEST['end_time']);
        } else {
            if (!empty($_REQUEST['start_time'])) {
                $map['a.create_time'] = array('egt', strtotime($_REQUEST['start_time']));
                $this->assign('start_time', $_REQUEST['start_time']);
            }
            if (!empty($_REQUEST['end_time'])) {
                $map['a.create_time'] = array('elt', strtotime($_REQUEST['end_time']));
                $this->assign('end_time', $_REQUEST['end_time']);
            }
        }

        $count = D('order a')->join('left join teach_ucenter_member c on a.uid = c.id')->where($map)->count();
        $Page = new \Think\Page($count, 10, array('type' => $_REQUEST['type'], 'mobile' => $_REQUEST['mobile'], 'order_sn' => $_REQUEST['order_sn'], 'start_time' => $_REQUEST['start_time'], 'end_time' => $_REQUEST['end_time']));// 实例化分页类 传入总记录数和每页显示的记录数(25)
        $list = D('order a')->field('a.*,c.username,c.mobile,c.id_card')->join('left join teach_ucenter_member c on a.uid = c.id')->where($map)->order('a.id desc')->limit($Page->firstRow . ',' . $Page->listRows)->order('id desc')->select();
        foreach ($list as $key => $item) {
            //单价
            $price = D('vice_order')->where(array('order_id' => $item['id']))->SUM('price');
            $list[$key]['price'] = $price ? $price : 0;

            $course_name = "";
            $price = 0.00;
            $vice_order = D('vice_order')->where(array('order_id'=>$item['id']))->select();
            foreach ($vice_order as $k=>$vo) {
                $course_name .= $vo['name'].",";
                $price = $price+$vo['old_price'];
            }
            $list[$key]['course_name'] = $course_name;
            $list[$key]['price'] = $price;

            $list[$key]['pay_time'] = $item['pay_time']?date('Y-m-d',$item['pay_time']):'-';
        }

        $this->assign('_list', $list);
        $show = $Page->show();// 分页显示输出
        $this->assign("_page", $show);

        $this->assign('cur','交易管理');
        $this->display();
    }

    /**
     * Mr.Jiang
     * 交易管理详情
     */
    public function orderDetails()
    {
        $id = $_REQUEST['id'];
        //订单信息
        $order = D('order')->where(array('id' => $id))->find();
        $order['pay_time'] = $order['pay_time']?date('Y-m-d H:i',$order['pay_time']):'-';

        //用户信息
        $user = D('ucenter_member')->where(array('id' => $order['uid']))->find();

        //商品信息
        $list = D('vice_order')->where(array('order_id' => $id))->select();
        foreach ($list as $key=>$item) {
            $path = D('picture')->where(array('id'=>$item['img']))->getField('path');
            $list[$key]['img_path'] = $path?$path:'';

        }

        $this->assign('order', $order);
        $this->assign('user', $user);
        $this->assign('list', $list);
        $this->assign('cur','交易管理');
        $this->display();
    }

    /**
     * Mr.Jiang
     * 收费管理
     */
    public function charge()
    {
        $map['iid'] = session('iid');
        if ($_REQUEST['mobile'] != '') {
            $map['mobile'] = array('like', '%' . $_REQUEST['mobile'] . '%');
            $this->assign('mobile', $_REQUEST['mobile']);
        }

        if (!empty($_REQUEST['start_time']) && !empty($_REQUEST['end_time'])) {
            $map['create_time'] = array(array('egt', strtotime($_REQUEST['start_time'])), array('elt', strtotime($_REQUEST['end_time']." 23:59:59")), 'AND');
            $this->assign('start_time', $_REQUEST['start_time']);
            $this->assign('end_time', $_REQUEST['end_time']);
        } else {
            if (!empty($_REQUEST['start_time'])) {
                $map['create_time'] = array('egt', strtotime($_REQUEST['start_time']));
                $this->assign('start_time', $_REQUEST['start_time']);
            }
            if (!empty($_REQUEST['end_time'])) {
                $map['create_time'] = array('elt', strtotime($_REQUEST['end_time']." 23:59:59"));
                $this->assign('end_time', $_REQUEST['end_time']);
            }
        }

        $count = D('charge')->where($map)->count();
        $Page = new \Think\Page($count, 10, array('mobile' => $_REQUEST['mobile'], 'start_time' => $_REQUEST['start_time'], 'end_time' => $_REQUEST['end_time']));// 实例化分页类 传入总记录数和每页显示的记录数(25)
        $list = D('charge')->where($map)->limit($Page->firstRow . ',' . $Page->listRows)->order('create_time desc')->select();
        foreach ($list as $key=>$item) {
            $path = D('picture')->where(array('id'=>$item['voucher']))->getField('path');
            $list[$key]['path'] = $path?$path:'';
        }

        $this->assign('_list', $list);
        $show = $Page->show();// 分页显示输出
        $this->assign("_page", $show);

        $this->assign('cur','收费管理');
        $this->display();
    }

    /**
     * Mr.Jiang
     * 新增收费
     */
    public function addCharge()
    {
        if (IS_POST) {
            $data['iid'] = session('iid');
            $data['name'] = $_REQUEST['name'];
            $data['mobile'] = $_REQUEST['mobile'];
            $data['receivable'] = $_REQUEST['receivable'];
            $data['net_receipts'] = $_REQUEST['net_receipts'];
            $data['remarks'] = $_REQUEST['remarks'];
            $data['recruiters'] = $_REQUEST['recruiters'];
            $data['voucher'] = $_REQUEST['voucher'];
            $data['type'] = $_REQUEST['type'];
            if ($data['name'] == '') {
                $this->error("请输入姓名");
            }

            if ($data['mobile'] == '') {
                $this->error("请输入手机号");
            }

            if (empty($data['voucher'])) {
                $this->error("请上传收费凭证");
            }

            $time = time();
            $data['create_time'] = $time;
            $data['update_time'] = $time;
            $result = D('charge')->add($data);
            if ($result) {
                if(session('Supertube')==2){
                    //不记录超管的 只记录这种有权限的
                    $data['account_id']=session('user_id');
                    $data['create_time']=time();
                    $data['ip_address']=$_SERVER["REMOTE_ADDR"];
                    $data['content']='收费管理'.'-'.'新增收费';
                    M('account_log')->add($data);
                }
                $this->success("新增成功", U('charge'));
            } else {
                $this->error("新增失败");
            }
        } else {
            $this->assign('cur','收费管理');
            $this->display();
        }
    }

    //tzb 财务统计
    public function statistics(){
        //收入
        $map['iid']=session('iid');
        $map['status']=array('between',"1,5");
        $map['type']=array('neq',4);
        $list=M('order')->where($map)->select();
        $sum=0;
        $total_price=0;
        foreach($list as $k=>$v){
            $sum+=$v['all_price'];//应收
            $total_price+=$v['pay_price'];//实收
        }
        $this->assign('sum',$sum);
        $this->assign('total_price',$total_price);
        //支出
        $iid=session('iid');
        $zc=0;
        $z=M('charge')->where("iid=$iid && type=2")->select();
        foreach($z as $k=>$v){
            $zc+=$v['net_receipts'];
        }
        $this->assign('zc',$zc);
        //统计
        $search=$_REQUEST['search']?$_REQUEST['search']:1;
        $this->assign('search',$search);
        if($search==1){
            //今天
            $line_time = date('m-d',time());
            $this->assign('line_time',$line_time);
            $bbtime=date('Y-m-d',time());//今天
            $ebtime=date('Y-m-d',strtotime("+1 day"));//明天
            //这个时间查询以前是日期查询 不是时间戳  要改一下
            $btime=strtotime($bbtime);
            $etime=strtotime($ebtime);
            $condition['create_time']=array('between',"$btime,$etime");
            $condition['iid']=session('iid');
            $list=M('order')->where($condition)->select();
            $all_sum=0;
            $total_sum=0;
            foreach($list as $k=>$v){
                $all_sum+=$v['all_price'];//应付金额
                $total_sum+=$v['pay_price'];
            }

        }elseif($search==2){
            //昨天
            $line_time = date('m-d',strtotime("-1 day"));
            $this->assign('line_time',$line_time);
            $bbtime=date('Y-m-d',strtotime("-1 day"));
            $ebtime=date('Y-m-d',time());//今天
            //这个时间查询以前是日期查询 不是时间戳  要改一下
            $btime=strtotime($bbtime);
            $etime=strtotime($ebtime);
            $condition['create_time']=array('between',"$btime,$etime");
            $condition['iid']=session('iid');
            $list=M('order')->where($condition)->select();
            $all_sum=0;
            $total_sum=0;
            foreach($list as $k=>$v){
                $all_sum+=$v['all_price'];//应付金额
                $total_sum+=$v['pay_price'];
            }


        }elseif($search==3){
            //最近七天
            $line_time = date('m-d',strtotime("-6 day"));
            $line_time .= ",".date('m-d',strtotime("-5 day"));
            $line_time .= ",".date('m-d',strtotime("-4 day"));
            $line_time .= ",".date('m-d',strtotime("-3 day"));
            $line_time .= ",".date('m-d',strtotime("-2 day"));
            $line_time .= ",".date('m-d',strtotime("-1 day"));
            $line_time .= ",".date('m-d',time());
            $this->assign('line_time',$line_time);
            $bbtime=date('Y-m-d',strtotime("-6 day"));//前第七天
            $ebtime=date('Y-m-d',strtotime("-5 day"));//
            //这个时间查询以前是日期查询 不是时间戳  要改一下
            $btime=strtotime($bbtime);
            $etime=strtotime($ebtime);
            $condition['create_time']=array('between',"$btime,$etime");
            $condition['iid']=session('iid');
            $list=M('order')->where($condition)->select();
            $all_sum0=0;
            $total_sum0=0;
            foreach($list as $k=>$v){
                $all_sum0+=$v['all_price'];//应付金额
                $total_sum0+=$v['pay_price'];
            }
            //第六天
            $bbtime=date('Y-m-d',strtotime("-5 day"));//前第六天
            $ebtime=date('Y-m-d',strtotime("-4 day"));//
            //这个时间查询以前是日期查询 不是时间戳  要改一下
            $btime=strtotime($bbtime);
            $etime=strtotime($ebtime);
            $condition['create_time']=array('between',"$btime,$etime");
            $condition['iid']=session('iid');
            $list=M('order')->where($condition)->select();
            $all_sum1=0;
            $total_sum1=0;
            foreach($list as $k=>$v){
                $all_sum1+=$v['all_price'];//应付金额
                $total_sum1+=$v['pay_price'];
            }
            //第五天
            $bbtime=date('Y-m-d',strtotime("-4 day"));//前第五天
            $ebtime=date('Y-m-d',strtotime("-3 day"));//
            //这个时间查询以前是日期查询 不是时间戳  要改一下
            $btime=strtotime($bbtime);
            $etime=strtotime($ebtime);
            $condition['create_time']=array('between',"$btime,$etime");
            $condition['iid']=session('iid');
            $list=M('order')->where($condition)->select();
            $all_sum2=0;
            $total_sum2=0;
            foreach($list as $k=>$v){
                $all_sum2+=$v['all_price'];//应付金额
                $total_sum2+=$v['pay_price'];
            }
                        //第四天
            $bbtime=date('Y-m-d',strtotime("-3 day"));//前第四天
            $ebtime=date('Y-m-d',strtotime("-2 day"));//
            //这个时间查询以前是日期查询 不是时间戳  要改一下
            $btime=strtotime($bbtime);
            $etime=strtotime($ebtime);
            $condition['create_time']=array('between',"$btime,$etime");
            $condition['iid']=session('iid');
            $list=M('order')->where($condition)->select();
            $all_sum3=0;
            $total_sum3=0;
            foreach($list as $k=>$v){
                $all_sum3+=$v['all_price'];//应付金额
                $total_sum3+=$v['pay_price'];
            }
            //第三天
            $bbtime=date('Y-m-d',strtotime("-2 day"));//前第三天
            $ebtime=date('Y-m-d',strtotime("-1 day"));//
            //这个时间查询以前是日期查询 不是时间戳  要改一下
            $btime=strtotime($bbtime);
            $etime=strtotime($ebtime);
            $condition['create_time']=array('between',"$btime,$etime");
            $condition['iid']=session('iid');
            $list=M('order')->where($condition)->select();
            $all_sum4=0;
            $total_sum4=0;
            foreach($list as $k=>$v){
                $all_sum4+=$v['all_price'];//应付金额
                $total_sum4+=$v['pay_price'];
            }
                        //第二天
            $bbtime=date('Y-m-d',strtotime("-1 day"));//昨天
            $ebtime=date('Y-m-d',time());//
            //这个时间查询以前是日期查询 不是时间戳  要改一下
            $btime=strtotime($bbtime);
            $etime=strtotime($ebtime);
            $condition['create_time']=array('between',"$btime,$etime");
            $condition['iid']=session('iid');
            $list=M('order')->where($condition)->select();
            $all_sum5=0;
            $total_sum5=0;
            foreach($list as $k=>$v){
                $all_sum5+=$v['all_price'];//应付金额
                $total_sum5+=$v['pay_price'];
            }
            //今天
            $bbtime=date('Y-m-d',time());//今天
            $ebtime=date('Y-m-d',strtotime("+1 day"));//明天
            //这个时间查询以前是日期查询 不是时间戳  要改一下
            $btime=strtotime($bbtime);
            $etime=strtotime($ebtime);
            $condition['create_time']=array('between',"$btime,$etime");
            $condition['iid']=session('iid');
            $list=M('order')->where($condition)->select();
            $all_sum6=0;
            $total_sum6=0;
            foreach($list as $k=>$v){
                $all_sum6+=$v['all_price'];//应付金额
                $total_sum6+=$v['pay_price'];
            }
            $all_sum=$all_sum0.','.$all_sum1.','.$all_sum2.','.$all_sum3.','.$all_sum4.','.$all_sum5.','.$all_sum6;
            $total_sum=$total_sum0.','.$total_sum1.','.$total_sum2.','.$total_sum3.','.$total_sum4.','.$total_sum5.','.$total_sum6;
            // print_r($all_sum);die;
        }elseif($search==4){
            $start_time = strtotime($_REQUEST['start_time']);
            $end_time = strtotime($_REQUEST['end_time']." 23:59:59");
            if(!empty($_REQUEST['start_time']) && !empty($_REQUEST['end_time'])){
                $where .= " and create_time >= {$start_time} and create_time <= {$end_time}";
                $this->assign('start_time',$_REQUEST['start_time']);
                $this->assign('end_time',$_REQUEST['end_time']);
            }else {
                if(!empty($_REQUEST['start_time'])){
                    $where .= " and create_time >= {$start_time}";
                    $this->assign('start_time',$_REQUEST['start_time']);
                }
                if(!empty($_REQUEST['end_time'])){
                    $where .= " and create_time <= {$end_time}";
                    $this->assign('end_time',$_REQUEST['end_time']);
                }
            }




        //开始时间 ~ 结束时间
        $start_date=I('start_time');
        $end_date=I('end_time');
//
        //如果为空，则从今天的0点为开始时间
        if(!empty($start_date))
            $start_date=date('Y-m-d',strtotime($start_date));
        else
            $start_date=date('Y-m-d',time());
//
        //如果为空，则以明天的0点为结束时间（不存在24:00:00，只会有00:00:00）
        if(!empty($end_date))
            $end_date=date('Y-m-d',strtotime($end_date));
        else
            $end_date=date('Y-m-d',strtotime('+1 day'));

        //between 查询 要求必须是从低到高
        if($start_date>$end_date)
        {
            $ttt=$start_date;
            $start_date=$end_date;
            $end_date=$ttt;
        }elseif($start_date==$end_date){
            echo '时间输入错误';die;
        }
        $time_s=strtotime($start_date);
        $time_e=strtotime($end_date);

        //生成中间时间点数组（时间戳格式、日期时间格式、日期序列）
        $days_inline_array=array();
        $times_inline_array=array();
        $days_list=array();
        //判断开始和结束时间是不是在同一天
        $days_inline_array[0]=$start_date;
        $times_inline_array[0]=$time_s;
        if(
            date('Y-m-d',$time_s)
            ==date('Y-m-d',$time_e)
        ){
            $days_inline_array[1]=$end_date;
            $times_inline_array[1]=$time_e;
            $days_list[]=date('Y-m-d',$time_s);
        }
        else
        {
            /**
             * A.取开始时间的第二天凌晨0点
             * B.用结束时间减去A
             * C.用B除86400取商，取余
             * D.用A按C的商循环+86400，取得分割时间点，如果C没有余数，则最后一个时间点与循环最后一个时间点一致
             */
            $A_temp=date('Y-m-d',$time_s+86400);
            $A=strtotime($A_temp);
            $B=$time_e-$A;
            $C_quotient=floor($B/86400);    //商舍去法取整
            $C_remainder=fmod($B,86400);               //余数

            $days_inline_array[1]=$A_temp;
            $times_inline_array[1]=$A;
            $days_list[]=date('Y-m-d',$A);
            for($increase_time=$A,$c_count_t=1;$c_count_t<=$C_quotient;$c_count_t++)
            {
                $increase_time+=86400;
                $days_inline_array[]=date('Y-m-d',$increase_time);
                $times_inline_array[]=$increase_time;
                $days_list[]=date('Y-m-d',$increase_time);
            }
            //如果有余数，则最后一个时间点大于循环最后一个时间点，但在同一天
            if($C_remainder)
            {
                $days_inline_array[]=$end_date;
                $times_inline_array[]=$time_e;
                //这里不再添加 $days_list，因为余数和最后一个凌晨0点必定是同一天
            }
        }

        // print_r($days_inline_array);die;
        foreach($days_inline_array as $k=>$v){
            if($k==0){
                $line_time=$v;
            }else{
                $line_time.=','.$v;
            }
            $btime=strtotime($v);
            $etime=$btime+86400;

            $condition['create_time']=array('between',"$btime,$etime");
            $condition['iid']=session('iid');
            $list=M('order')->where($condition)->select();
            // echo '<pre>';print_r($list);
            if(!$list){
                $all_summ[$k]=0;
                $total_summ[$k]=0;
            }else{
                foreach($list as $kk=>$vv){
                    $all_summ[$k]+=$vv['all_price'];//应付金额
                    $total_summ[$k]+=$vv['pay_price'];
                }
            }

        }
        // echo '<pre>';print_r($all_summ);die;
        foreach($all_summ as $k=>$v){
            $all.=','.$v;
            $total.=','.$total_summ[$k];
        }
        $all_sum=substr($all, 1);
        $total_sum=substr($total, 1);
        }
        $this->assign('sum1',100);
        $this->assign('sum2',160);
        $this->assign('all_sum',$all_sum);
        $this->assign('total_sum',$total_sum);
        $this->assign('line_time',$line_time);
        $this->assign('cur','财务统计');
        $this->display();
    }
}
